<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>确认支付页面</title>
    <!--bootstrap-->
    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="../js/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script src="../js/CacheUtil.js"></script>
    <script src="../js/HttpUtil.js"></script>
    <script src="../js/OrdersUtils.js"></script>
    <script src="../js/UserCacheUtil.js"></script>
</head>
<body>
<!--导入页面公共头部-->
<div class="Top_header"></div>




<nav class="navbar navbar-default col-xs-10 col-xs-offset-1" id="checkPay">
    <div class="container ">
        <div>
            <h3 style="color: red">请确认订单编号和总金额！！！</h3>
        </div>
        <div class="panel-body" >
            <table cellpadding="0" cellspacing="0" align="center" width="100%"
                   class="table table-striped table-bordered table-hover" >
                <tr>
                    <td style="color:#ff4837;">订单编号:</td>
                    <td>{order.oId}</td>
                    <td style="color:#ff4038;">订单总金额:</td>
                    <td>￥{orders.oCount}</td>
                </tr>
                <tr>
                    <td align="right" colspan="4" style="margin-right: 40px;">
                        <button onclick="toPay(payParams);" class="btn btn-info btn-sm">确认支付</button>
                    </td>
                </tr>
            </table>
        </div>
    </div><!-- /.container-fluid -->
</nav>




<script>
    var payParams = getPayParams();
    // let payParams = JSON.parse(o);
    //获取上个页面传递的参数
    console.log("获取到的订单编号：");
    console.log(payParams.oId);
    console.log("获取到的订单总金额：");
    console.log(payParams.oCount);

    //字段替换
    $(drawingCheckPay(payParams));

    $(".Top_header").load("/shop-app/include/header.html");


    //将支付参数传递给后端
    function toPay(payParams) {
        console.log("订单编号：");
        console.log(payParams.oId);
        console.log("订单总金额：");
        console.log(payParams.oCount);

        //发起Ajax请求
        $.ajax({
            url: '/shop-api/aliPay/pay',
            type: 'post',
            data: JSON.stringify({
                oId:payParams.oId,
                oCount:payParams.oCount
            }),
            contentType: "application/json",
            success: function (payHtml) {
                console.log(typeof payHtml);
                //存入支付宝支付html字符串
                console.log(payHtml);
                setPayHtml(payHtml);
                //重定向至支付宝支付页面
                $(window).attr('location', '/shop-app/orders/pay.html');
            }
        })
    }
</script>
</body>
</html>